/**
 * 游戏Mock数据
 * 用于前端开发测试
 */

// 模拟房间列表
export const mockRoomList = [
  {
    id: 1,
    roomNo: '123456',
    ownerName: '张三',
    ownerId: 1,
    playerCount: 2,
    status: 0, // 0-等待中 1-准备中 2-游戏中 3-已结束
    hasPassword: false,
    createTime: '2025-11-10 10:00:00'
  },
  {
    id: 2,
    roomNo: '789012',
    ownerName: '李四',
    ownerId: 2,
    playerCount: 4,
    status: 0,
    hasPassword: true,
    createTime: '2025-11-10 10:05:00'
  },
  {
    id: 3,
    roomNo: '345678',
    ownerName: '王五',
    ownerId: 3,
    playerCount: 3,
    status: 2,
    hasPassword: false,
    createTime: '2025-11-10 10:10:00'
  }
]

// 模拟房间详情
export const mockRoomDetail = {
  room: {
    id: 1,
    roomNo: '123456',
    ownerName: '张三',
    ownerId: 1,
    status: 0,
    createTime: '2025-11-10 10:00:00'
  },
  players: [
    {
      userId: 1,
      nickName: '张三',
      avatar: '/static/images/profile.jpg',
      isReady: false,
      isOwner: true,
      position: 0 // 0-下 1-左 2-上 3-右
    },
    {
      userId: 2,
      nickName: '李四',
      avatar: '/static/images/profile.jpg',
      isReady: true,
      isOwner: false,
      position: 1
    }
  ]
}

// 模拟游戏状态
export const mockGameStatus = {
  roomId: 1,
  status: 2, // 游戏中
  currentPlayer: 0, // 当前出牌玩家位置
  currentCards: [], // 当前牌桌上的牌
  phase: 'playing', // 游戏阶段：black_a(亮黑A) / red_a(反红A) / playing(出牌中) / finished(已结束)
  players: [
    {
      userId: 1,
      position: 0,
      cardCount: 10, // 剩余牌数
      hasBlackA: true, // 是否有黑A
      showedBlackA: false, // 是否已亮黑A
      hasRedA: false,
      showedRedA: false,
      lastAction: null // 最后操作：play/pass
    },
    {
      userId: 2,
      position: 1,
      cardCount: 10,
      hasBlackA: false,
      showedBlackA: false,
      hasRedA: true,
      showedRedA: false,
      lastAction: null
    },
    {
      userId: 3,
      position: 2,
      cardCount: 10,
      hasBlackA: true,
      showedBlackA: true,
      hasRedA: false,
      showedRedA: false,
      lastAction: null
    },
    {
      userId: 4,
      position: 3,
      cardCount: 10,
      hasBlackA: false,
      showedBlackA: false,
      hasRedA: true,
      showedRedA: true,
      lastAction: null
    }
  ],
  myCards: [
    { suit: '♠', rank: 'A', value: 14, id: '♠A' },
    { suit: '♥', rank: 'K', value: 13, id: '♥K' },
    { suit: '♦', rank: 'Q', value: 12, id: '♦Q' },
    { suit: '♣', rank: 'J', value: 11, id: '♣J' },
    { suit: '♠', rank: '10', value: 10, id: '♠10' },
    { suit: '♥', rank: '9', value: 9, id: '♥9' },
    { suit: '♦', rank: '8', value: 8, id: '♦8' },
    { suit: '♣', rank: '7', value: 7, id: '♣7' },
    { suit: '♠', rank: '6', value: 6, id: '♠6' },
    { suit: '♥', rank: '5', value: 5, id: '♥5' }
  ]
}

// 模拟游戏结算
export const mockGameResult = {
  roomId: 1,
  winner: {
    userId: 1,
    nickName: '张三',
    position: 0
  },
  players: [
    {
      userId: 1,
      nickName: '张三',
      position: 0,
      score: 3, // 得分
      blackABonus: 1, // 黑A加分
      redABonus: 0, // 红A加分
      totalScore: 4
    },
    {
      userId: 2,
      nickName: '李四',
      position: 1,
      score: -1,
      blackABonus: 0,
      redABonus: 0,
      totalScore: -1
    },
    {
      userId: 3,
      nickName: '王五',
      position: 2,
      score: -1,
      blackABonus: 0,
      redABonus: -1,
      totalScore: -2
    },
    {
      userId: 4,
      nickName: '赵六',
      position: 3,
      score: -1,
      blackABonus: 0,
      redABonus: 0,
      totalScore: -1
    }
  ],
  duration: 300, // 游戏时长（秒）
  endTime: '2025-11-10 10:30:00'
}

/**
 * Mock API响应格式
 */
export function mockResponse(data, msg = '操作成功') {
  return {
    code: 200,
    msg,
    data
  }
}

export function mockError(msg = '操作失败') {
  return {
    code: 500,
    msg,
    data: null
  }
}
